Ext.namespace('Ext.translate');

Ext.translate.LanguageCombo = Ext.extend(Ext.ux.form.IconCombo, {
	
    fieldLabel: 'Select Language',
    store: new Ext.data.SimpleStore({
      fields: ['languageCode', 'languageName', 'countryFlag'],
      data: Ext.translate.languages
    }),
    valueField: 'languageName',
    value: Ext.translate.defaultLanguage,
    displayField: 'languageName',
    iconClsField: 'countryFlag',
    triggerAction: 'all',
    editable: false,
    disabled : true ,
    mode: 'local',

    initComponent : function(){
		Ext.translate.LanguageCombo.superclass.initComponent.call(this);
		this.on('select',this.selectEvent,this);
		Ext.translate.LanguageCombo.superclass.initComponent.apply(this, arguments);
	},
	
	onRender : function(){
		Ext.translate.LanguageCombo.superclass.onRender.apply(this, arguments);
		Ext.translate.Manager.getSupportedLanguages(this.renderEvent.createDelegate(this));
	},
	
	renderEvent : function (){
	  this.store.loadData(Ext.translate.languages);
	  Ext.translate.Manager.generateFlagsCSS(Ext.translate.languages);
	  this.enable();	
	  this.setValue(Ext.translate.currentLanguage);
	},
	
	selectEvent : function (){
		  var lng = this.getValue();
	      Ext.translate.Manager.setlanguage(lng);
	}
	
});



  
